package android.androidapp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class LocationInfo implements Comparable{
	
	public int id;
	public String name;
	public Double longitude;
	public Double latitude;
	public Double lastDistanceFromPosition;
	
	public void updateDistance(Double Lat, Double Long)
	{
		double latDiff = Math.abs(this.latitude - Lat);
		double longDiff = Math.abs(this.longitude - Long);
		this.lastDistanceFromPosition = latDiff + longDiff;
		
	}

	@Override
	public int compareTo(Object another) {
		LocationInfo compareToObject = (LocationInfo)another;
		if(this.lastDistanceFromPosition == compareToObject.lastDistanceFromPosition)
			return 0;
		else if(this.lastDistanceFromPosition < compareToObject.lastDistanceFromPosition)
			return -1;
		else
			return 1;
	}
	

}
